package com.taocore.top.title;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

import com.taobao.api.domain.ArticleUserSubscribe;

public class Utils implements Constants{

	public static boolean isAdmin(long userId)
	{
		return userId == ADMIN_ID;
	}
	
	public static int getVersion(String itemCode)
	{
		if (Arrays.asList(VERSION_2_ITEMS).contains(itemCode))
		{
			return 2;
		}
		else
		{
			return 1;
		}
	}
	
	public static boolean verifySubscription(List<ArticleUserSubscribe> subscriptions, String itemCode)
    {
		if (subscriptions != null)
		{
			for (ArticleUserSubscribe sub : subscriptions)
			{
				if (itemCode.equals(sub.getItemCode()) && new Date().before(sub.getDeadline()))
				{
					return true;
				}
			}
		}
		return false;
    }
}
